package cn.zb.zbrhback.sys.service.impl;

import cn.zb.zbrhback.sys.domain.Dictionary;
import cn.zb.zbrhback.sys.domain.Dictionaryitem;
import cn.zb.zbrhback.sys.mapper.DictionaryMapper;
import cn.zb.zbrhback.sys.mapper.DictionaryitemMapper;
import cn.zb.zbrhback.sys.service.IDictionaryService;
import cn.zb.zbrhback.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zb
 * @since 2023-03-13
 */
@Service
public class DictionaryServiceImpl extends BaseServiceImpl<Dictionary> implements IDictionaryService {
    @Autowired
    private DictionaryMapper dictionaryMapper;
    @Autowired
    private DictionaryitemMapper dictionaryitemMapper;

    @Override
    @Transactional
    public void deleteById(Serializable id) {
        dictionaryitemMapper.deleteParentId(id);
        dictionaryMapper.deleteById(id);
    }

    @Override
    public void batchDelete(List<Long> ids) {
        for (Long id : ids) {
            dictionaryitemMapper.deleteParentId(id);
            dictionaryMapper.deleteById(id);
        }
    }

    @Override
    public void additem(Dictionaryitem dictionaryitem) {
        System.out.println("字典新增明细"+dictionaryitem);
        dictionaryitemMapper.additem(dictionaryitem);
    }
}
